package com.zego.wawaji.ui.coupon.panel.invalid;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zego.wawaji.R;
import com.zego.wawaji.ui.base.ExBaseAdapter;
import com.zego.wawaji.ui.coupon.bean.Coupon;

import java.util.List;

/**
 * Created by Su on 2018/2/9.
 */
public class InvalidAdapter extends ExBaseAdapter<Coupon> {

    public InvalidAdapter(Context context, List<Coupon> datas) {
        super(context, datas);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder holder;
        if (convertView == null) {
            convertView = inflate(R.layout.coupon_invalid_item);
            holder = new MyViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (MyViewHolder) convertView.getTag();
        }
        final Coupon data = getItem(position);

        holder.coupon_coin.setText(String.valueOf(data.getWwCoinZs()));
        holder.coupon_title.setText(data.getTitle());
        holder.coupon_remark.setText(data.getRemark());
        holder.coupon_time.setText("有效期限：" + data.getExpireTime());
        return convertView;
    }


    private class MyViewHolder {
        private TextView coupon_coin, coupon_title, coupon_remark, coupon_time;

        public MyViewHolder(View convertView) {
            initView(convertView);
        }

        private void initView(View convertView) {
            coupon_coin = (TextView) convertView.findViewById(R.id.coupon_coin);
            coupon_title = (TextView) convertView.findViewById(R.id.coupon_title);
            coupon_remark = (TextView) convertView.findViewById(R.id.coupon_remark);
            coupon_time = (TextView) convertView.findViewById(R.id.coupon_time);
        }
    }
}
